//
//  SMSRequestProvider.m
//  SulitLoan
//
//  Created by 虞嘉伟 on 2025/2/26.
//  
  

#import "DeviceRequestProvider.h"
#import "DeviceRequest.h"
#import "Base64Help.h"


@implementation DeviceRequestProvider

+ (void)requestTrackWithDeviceInfo:(NSDictionary *)info success:(void(^)(NSDictionary *dict))success failure:(void(^)(YTKRequest *request))failure {
    DeviceRequest *request = [DeviceRequest new];
    request.bounding = [Base64Help base64WithDictionary:info];
#ifdef DEBUG
    //request.bounding = @"622025022613515356570155";
#endif
    [request startWithCompletionBlockWithSuccess:^(__kindof YTKBaseRequest * _Nonnull request) {
        NSDictionary *dict = request.responseObject;
        if (![dict isKindOfClass:NSDictionary.class]) {
            !failure ?: failure(request);
            return;
        }
        if ([dict[@"weeps"] intValue] == 0) {
            // 成功
            !success ?: success(dict[@"bounding"]);
        } else {
            !failure ?: failure(request);
        }
    } failure:^(__kindof YTKBaseRequest * _Nonnull request) {
        !failure ?: failure(request);
    }];
}



@end
